/**
 * 测试任务报告模板示例插件
 * 暴露 reportTemplates 数组：供系统自动聚合，用于测试任务报告生成。
 * 每个模板字段说明：
 *  - code: 模板唯一编码
 *  - name: 模板名称
 *  - test_mode: 适用测试模式（single|multi_similar|single_multi|multi_multi|all）
 *  - description: 描述
 *  - rule_expr: 规则表达式（目前仅支持 priority:n 选择优先级）
 *  - field_schema: 自定义扩展字段schema { fields:[ { key,label,type,default,required,enum,min,max,desc } ] }
 *  - structure: 报告结构定义（极简示例）
 */
class PromptReportTemplateSamplePlugin {
  constructor(){
    this.name = 'PromptReportTemplateSamplePlugin';
    this.type = 'reportTemplatePlugin';
    this.version = '1.0.0';

    this.reportTemplates = [
      {
        code: 'basic_summary_v2',
        name: '基础汇总报告（升级版）',
        test_mode: 'all',
        description: '展示基础统计、模型参数、压测目标、人工评估、综合结论及模型回复节选。',
        rule_expr: 'priority:10',
        field_schema: {
          fields: [
            { key: 'author', label: '报告作者', type: 'string', required: true, default: '匿名' },
            { key: 'auditor', label: '审核人', type: 'string', required: false },
            { key: 'target_desc', label: '压测目标描述', type: 'string', required: true },
            { key: 'manual_score', label: '人工评估分数', type: 'number', min: 0, max: 100 },
            { key: 'include_case_table', label: '包含用例表', type: 'boolean', default: true },
            { key: 'case_table_limit', label: '用例表最大行', type: 'number', min: 0, max: 2000, default: 200 },
            { key: 'focus_metric', label: '关注指标', type: 'enum', enum: ['success_rate','avg_duration'], default: 'success_rate', desc: '用于高亮展示的核心指标' }
          ]
        },
        structure: {
          title: 'Prompt 测试任务报告 - 基础汇总（升级版）',
          sections: [
            { key: 'meta', title: '基本信息', type: 'meta', render: 'table', dataSource: 'task' },
            { key: 'target', title: '压测目标', type: 'target', render: 'text', dataSource: 'ext.target_desc' },
            { key: 'model', title: '压测模型', type: 'model_table', render: 'table', dataSource: 'model_types' },
            { key: 'content', title: '压测内容', type: 'content', render: 'table', dataSource: ['prompt_text', 'form_data'] },
            { key: 'task', title: '压测任务', type: 'task', render: 'table', dataSource: 'task_params' },
            { key: 'metrics', title: '核心指标', type: 'metric_summary', render: 'table', dataSource: 'metrics' },
            { key: 'analysis', title: '压测分析', type: 'analysis', render: 'text', dataSource: 'analysis' },
            { key: 'manual', title: '人工评估', type: 'manual', render: 'table', dataSource: 'ext.manual_score' },
            { key: 'conclusion', title: '综合结论', type: 'conclusion', render: 'text', dataSource: 'conclusion' },
            { key: 'appendix', title: '模型回复内容清单节选', type: 'appendix', render: 'log_table', dataSource: 'ai_prompt_log' }
          ]
        }
      },
      {
        code: 'multi_model_deep_v2',
        name: '多模型深度分析（升级版）',
        test_mode: 'single_multi',
        description: '适用于单提示词多模型场景，增加差异化分析、目标、人工评估、结论与回复节选。',
        rule_expr: 'priority:15',
        field_schema: {
          fields: [
            { key: 'author', label: '作者', type: 'string', required: true },
            { key: 'target_desc', label: '压测目标描述', type: 'string', required: true },
            { key: 'manual_score', label: '人工评估分数', type: 'number', min: 0, max: 100 },
            { key: 'highlight_threshold', label: '差异高亮阈值(成功率差)', type: 'number', min: 0, max: 1, default: 0.05 },
            { key: 'show_raw', label: '展示原始JSON', type: 'boolean', default: false }
          ]
        },
        structure: {
          title: 'Prompt 测试任务报告 - 多模型深度分析（升级版）',
          sections: [
            { key: 'meta', title: '基本信息', type: 'meta', render: 'table', dataSource: 'task' },
            { key: 'target', title: '压测目标', type: 'target', render: 'text', dataSource: 'ext.target_desc' },
            { key: 'metrics', title: '核心指标', type: 'metric_summary', render: 'table', dataSource: 'metrics' },
            { key: 'diff', title: '差异分析', type: 'diff_analysis', render: 'table', dataSource: 'diff' },
            { key: 'models', title: '模型详情', type: 'model_table', render: 'table', dataSource: 'model_types' },
            { key: 'manual', title: '人工评估', type: 'manual', render: 'table', dataSource: 'ext.manual_score' },
            { key: 'conclusion', title: '综合结论', type: 'conclusion', render: 'text', dataSource: 'conclusion' },
            { key: 'appendix', title: '模型回复内容清单节选', type: 'appendix', render: 'log_table', dataSource: 'ai_prompt_log' },
            { key: 'raw', title: '原始数据', type: 'raw_json', render: 'json', dataSource: 'raw', conditional: 'ext.show_raw' }
          ]
        }
      }
    ];
  }
}

module.exports = PromptReportTemplateSamplePlugin;
